package com.aifast.system.sys.controller;

import com.aifast.common.annotations.AiIdempotent;
import com.aifast.common.base.R;
import com.aifast.common.layui.LayuiDataTable;
import com.aifast.system.sys.entity.SysNotice;
import com.aifast.system.sys.service.SysNoticeService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aifast.common.base.Controller;
/**
 * <p>
 * 公告 前端控制器
 * </p>
 *
 * @author fujian
 * @since 2022-04-01
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/sys/sysNotice")
public class SysNoticeController extends Controller {

    private final SysNoticeService service;

    @GetMapping("list")
    public LayuiDataTable list() {
        return service.list(getSearchValue(), getPage());
    }

    @AiIdempotent
    @PostMapping("add")
    public R add(SysNotice sysNotice) {
        return service.insertOrUpdate(sysNotice) ? OK() : ERROR();
    }

    @GetMapping("info")
    public R info() {
        return service.info(getInt("id"));
    }

    @AiIdempotent
    @GetMapping("del")
    public R del() {
        return service.del(getInt("id"), get("ids")) ? OK() : ERROR();
    }

}

